Overview

Row

aUSD Outstanding

$66,638,251.6 USD

aUSD Collateral Ratio

4.76x

Percentage of Collateral

21.02%

Row

  • As of 2022-08-21, the combined aUSD value minted is $66,638,251.6 USD.

  • $61,984,695.9 USD on Acala (as of block number 1687200) and $4,653,555.7 USD on Karura (as of block number 2493452).

  • The collateralizaion ratio is the value of the collateteral deposited divided by the amount of aUSD minted.

  • The combined collateralization ratio is 4.76x.

  • The ratio for the individual parachains are as follows: 14.21x for Acala and 4.74x for Karura.

  • The reciprocal of the collareralization ratio shows the stablecoin issuance as a percentage of collateral, which is 21.02% in aggregate.

  • Specifically, 7.04% for Acala and 21.1% for Karura.

Charts

Row

Components of Total Value Locked

Row

Row

Row

Row

Row

Minting data

Row

aUSD Issuance

blockAcala blockKarura Date aUSD_Karura aUSD_Acala aUSD_Total
1,093,548 1,963,028 2022-05-25 4,100,411 6,116,611 10,217,022
1,100,467 1,969,604 2022-05-26 4,072,206 6,058,377 10,130,583
1,107,371 1,975,998 2022-05-27 4,055,514 6,022,962 10,078,476
1,114,253 1,982,535 2022-05-28 4,063,472 6,057,937 10,121,410
1,121,139 1,988,972 2022-05-29 4,065,723 6,081,219 10,146,942
1,128,033 1,995,443 2022-05-30 4,075,179 6,121,133 10,196,312
1,134,939 2,001,782 2022-05-31 4,196,753 6,132,025 10,328,778
1,141,677 2,008,273 2022-06-01 4,184,512 6,138,539 10,323,051
1,148,531 2,014,698 2022-06-02 4,192,668 6,208,705 10,401,373
1,155,361 2,021,059 2022-06-03 4,151,279 6,161,418 10,312,697
1,162,191 2,027,513 2022-06-04 4,154,170 6,110,974 10,265,145
1,168,945 2,034,053 2022-06-05 4,166,220 6,123,639 10,289,859
1,175,760 2,040,490 2022-06-06 4,179,423 6,143,116 10,322,540
1,182,503 2,046,816 2022-06-07 4,177,516 6,141,992 10,319,507
1,189,273 2,053,305 2022-06-08 4,178,977 6,137,929 10,316,907
1,196,022 2,059,744 2022-06-09 4,177,130 6,170,211 10,347,341
1,202,808 2,066,092 2022-06-10 4,149,014 6,136,321 10,285,335
1,209,560 2,072,325 2022-06-11 4,102,379 6,074,914 10,177,292
1,216,309 2,078,699 2022-06-12 4,004,056 5,891,343 9,895,398
1,222,967 2,084,974 2022-06-13 3,729,152 5,577,153 9,306,304
1,229,621 2,091,245 2022-06-14 3,735,276 5,568,632 9,303,909
1,236,320 2,097,549 2022-06-15 3,788,931 5,315,691 9,104,622
1,242,989 2,103,874 2022-06-16 3,784,345 5,287,516 9,071,861
1,249,647 2,110,292 2022-06-17 3,780,450 5,278,713 9,059,163
1,256,310 2,116,724 2022-06-18 3,744,797 5,247,145 8,991,943
1,263,003 2,123,104 2022-06-19 3,770,456 5,272,379 9,042,835
1,269,614 2,129,497 2022-06-20 3,773,566 4,741,005 8,514,571
1,276,376 2,135,922 2022-06-21 3,819,698 4,369,718 8,189,416
1,283,096 2,142,278 2022-06-22 3,827,112 4,370,810 8,197,922
1,289,783 2,148,575 2022-06-23 3,829,884 4,383,622 8,213,505
1,296,569 2,155,139 2022-06-24 3,832,776 4,397,323 8,230,099
1,303,311 2,161,562 2022-06-25 3,852,269 4,383,177 8,235,446
1,310,012 2,168,013 2022-06-26 3,876,004 4,374,412 8,250,416
1,316,693 2,173,904 2022-06-27 3,839,320 4,375,858 8,215,178
1,323,587 2,179,759 2022-06-28 3,806,037 4,373,729 8,179,766
1,330,303 2,185,605 2022-06-29 3,806,447 4,356,996 8,163,443
1,337,106 2,191,479 2022-06-30 3,774,174 4,331,462 8,105,636
1,343,825 2,197,147 2022-07-01 3,780,968 4,341,066 8,122,034
1,350,568 2,202,851 2022-07-02 3,806,688 4,354,300 8,160,989
1,357,347 2,208,544 2022-07-03 3,808,055 4,364,355 8,172,409
1,364,102 2,214,453 2022-07-04 3,812,428 4,372,827 8,185,255
1,370,943 2,220,335 2022-07-05 3,814,667 4,361,714 8,176,381
1,377,797 2,226,215 2022-07-06 3,815,652 4,364,384 8,180,036
1,384,635 2,232,059 2022-07-07 3,828,444 4,348,406 8,176,850
1,391,485 2,237,967 2022-07-08 3,837,918 4,347,524 8,185,442
1,398,299 2,243,857 2022-07-09 3,838,538 4,359,566 8,198,105
1,405,185 2,249,769 2022-07-10 3,840,756 4,352,234 8,192,990
1,411,909 2,255,713 2022-07-11 4,109,701 4,392,931 8,502,632
1,418,742 2,261,599 2022-07-12 4,107,944 4,358,631 8,466,575
1,425,585 2,267,294 2022-07-13 4,111,157 4,375,114 8,486,271
1,432,337 2,273,077 2022-07-14 4,111,947 4,374,531 8,486,478
1,439,201 2,278,953 2022-07-15 4,116,349 4,358,426 8,474,775
1,446,008 2,284,856 2022-07-16 4,116,661 4,348,617 8,465,278
1,452,960 2,290,692 2022-07-17 4,103,475 4,358,982 8,462,457
1,459,795 2,296,494 2022-07-18 4,111,415 4,398,737 8,510,151
1,466,580 2,302,426 2022-07-19 4,120,933 4,454,538 8,575,471
1,473,380 2,308,357 2022-07-20 4,126,611 4,500,049 8,626,660
1,480,245 2,314,283 2022-07-21 4,135,964 4,499,787 8,635,751
1,487,055 2,320,158 2022-07-22 4,227,100 4,533,147 8,760,248
1,493,873 2,326,054 2022-07-23 4,262,965 4,597,204 8,860,169
1,500,756 2,332,160 2022-07-24 4,266,207 4,605,889 8,872,096
1,507,666 2,338,259 2022-07-25 4,265,334 4,580,132 8,845,466
1,514,538 2,344,082 2022-07-26 4,193,132 4,577,767 8,770,899
1,521,363 2,349,718 2022-07-27 4,212,560 4,613,498 8,826,057
1,528,147 2,355,349 2022-07-28 4,216,008 4,623,185 8,839,193
1,535,018 2,360,978 2022-07-29 4,222,698 4,634,895 8,857,593
1,541,851 2,366,635 2022-07-30 4,258,459 4,640,917 8,899,376
1,548,704 2,372,202 2022-07-31 4,262,927 4,660,909 8,923,837
1,555,507 2,377,806 2022-08-01 4,267,948 5,783,151 10,051,099
1,562,419 2,383,360 2022-08-02 4,717,685 5,761,618 10,479,303
1,569,336 2,388,999 2022-08-03 4,720,206 5,756,487 10,476,693
1,576,157 2,394,583 2022-08-04 4,709,731 5,800,920 10,510,651
1,583,026 2,400,226 2022-08-05 4,719,403 5,854,369 10,573,772
1,589,971 2,406,084 2022-08-06 4,723,547 5,925,218 10,648,764
1,596,911 2,411,957 2022-08-07 4,723,069 5,941,852 10,664,921
1,603,908 2,417,831 2022-08-08 4,752,236 6,012,468 10,764,704
1,610,881 2,423,819 2022-08-09 4,763,845 6,113,350 10,877,195
1,617,841 2,429,866 2022-08-10 4,794,960 6,211,274 11,006,234
1,624,758 2,435,795 2022-08-11 4,801,615 6,274,030 11,075,645
1,631,646 2,441,583 2022-08-12 4,809,207 6,355,909 11,165,116
1,638,589 2,447,671 2022-08-13 4,805,785 9,195,461 14,001,246
1,645,126 2,453,431 2022-08-14 4,776,775 3,032,634,308 3,037,411,083
1,652,177 2,459,363 2022-08-15 4,763,269 3,032,634,308 3,037,397,577
1,658,789 2,465,132 2022-08-16 4,750,309 1,739,774,069 1,744,524,379
1,664,775 2,470,878 2022-08-17 4,750,123 1,739,774,069 1,744,524,192
1,673,113 2,476,517 2022-08-18 4,739,200 1,739,774,069 1,744,513,269
1,673,479 2,482,075 2022-08-19 4,638,080 1,739,774,069 1,744,412,149
1,687,200 2,493,452 2022-08-21 4,653,556 61,984,696 66,638,252

Row

Sources and Notes

Please click on the Source Code link at the top of the document to see the full source code. Here is a summary:

aUSD

  • aUDS (or kUSD) obtained from the py-substrate-interface using function substrate.query(module=‘Tokens’,storage_function=‘TotalIssuance’, params = [{‘Token’: ‘AUSD’}], block_hash = hash)

Collateral data

Row

aUSD Collateral

aUSD Collateral on Acala
timestamp ACA DOT LCDOT LDOT tDOT Total
2022-05-25T00:00:00 33,726,475 879,184.8 19,267,881 36,049,747 0 89,923,289
2022-05-26T00:00:00 30,879,726 773,513.2 17,514,683 34,094,350 0 83,262,272
2022-05-27T00:00:00 29,399,218 758,920.9 17,289,830 34,175,171 0 81,623,140
2022-05-28T00:00:00 30,383,749 792,747.5 18,195,952 36,180,796 0 85,553,245
2022-05-29T00:00:00 31,538,173 831,780.5 19,039,993 37,364,204 0 88,774,150
2022-05-30T00:00:00 37,110,651 877,557.0 20,219,540 39,561,582 0 97,769,331
2022-05-31T00:00:00 35,937,942 835,802.9 20,012,386 40,073,959 0 96,860,090
2022-06-01T00:00:00 32,494,525 813,376.8 17,971,424 36,495,390 0 87,774,716
2022-06-02T00:00:00 34,622,926 958,341.1 18,980,145 38,373,731 0 92,935,143
2022-06-03T00:00:00 31,155,569 828,464.6 17,933,123 36,340,325 0 86,257,482
2022-06-04T00:00:00 32,049,466 834,350.1 18,027,942 36,871,081 0 87,782,839
2022-06-05T00:00:00 31,557,720 835,901.0 18,079,058 37,085,359 0 87,558,038
2022-06-06T00:00:00 32,149,212 858,791.5 18,148,319 37,656,963 0 88,813,285
2022-06-07T00:00:00 31,450,008 917,979.3 17,940,867 36,946,590 0 87,255,444
2022-06-08T00:00:00 30,275,763 915,780.5 17,413,019 36,642,380 0 85,246,943
2022-06-09T00:00:00 30,309,521 922,628.8 17,700,179 37,755,726 0 86,688,056
2022-06-10T00:00:00 28,214,617 875,142.9 16,656,549 35,508,739 0 81,255,048
2022-06-11T00:00:00 26,233,595 805,465.4 15,491,476 33,084,923 0 75,615,459
2022-06-12T00:00:00 22,991,572 755,318.7 14,364,876 30,900,261 0 69,012,028
2022-06-13T00:00:00 22,496,740 603,357.8 12,804,107 28,265,405 0 64,169,610
2022-06-14T00:00:00 23,222,224 632,095.6 13,644,103 30,129,663 0 67,628,085
2022-06-15T00:00:00 24,635,191 795,036.9 15,350,110 34,491,243 0 75,271,580
2022-06-16T00:00:00 21,455,791 698,138.4 13,074,550 28,884,839 0 64,113,318
2022-06-17T00:00:00 21,588,106 708,291.1 13,556,319 30,107,827 0 65,960,543
2022-06-18T00:00:00 20,495,011 698,151.5 12,940,192 29,219,980 0 63,353,334
2022-06-19T00:00:00 21,666,317 736,484.7 13,704,383 30,874,634 0 66,981,819
2022-06-20T00:00:00 21,933,866 757,604.7 15,344,393 32,331,287 0 70,367,150
2022-06-21T00:00:00 22,391,510 783,003.7 15,454,004 32,076,181 0 70,704,699
2022-06-22T00:00:00 21,110,303 751,727.2 14,816,964 30,849,626 0 67,528,621
2022-06-23T00:00:00 22,411,324 781,462.3 15,312,177 32,069,474 0 70,574,437
2022-06-24T00:00:00 23,120,727 811,492.4 16,312,613 34,050,408 0 74,295,241
2022-06-25T00:00:00 22,328,789 780,487.2 15,826,700 33,575,946 0 72,511,923
2022-06-26T00:00:00 21,583,988 798,118.8 15,836,322 32,745,570 0 70,964,000
2022-06-27T00:00:00 21,879,730 795,040.0 15,324,248 32,619,704 0 70,618,722
2022-06-28T00:00:00 19,847,103 737,016.7 14,300,964 30,529,655 0 65,414,739
2022-06-29T00:00:00 19,494,983 703,022.7 13,757,575 29,397,328 0 63,352,909
2022-06-30T00:00:00 19,174,576 680,719.4 13,339,374 28,703,383 0 61,898,052
2022-07-01T00:00:00 18,991,081 667,664.3 13,317,313 29,121,571 0 62,097,629
2022-07-02T00:00:00 18,563,027 671,815.6 13,376,045 29,315,228 0 61,926,116
2022-07-03T00:00:00 18,406,482 706,142.6 13,374,999 29,354,634 0 61,842,258
2022-07-04T00:00:00 20,295,676 728,463.1 13,951,594 30,848,872 0 65,824,604
2022-07-05T00:00:00 18,995,785 707,868.0 13,447,543 29,737,130 0 62,888,326
2022-07-06T00:00:00 19,445,111 710,456.6 13,631,510 30,191,768 0 63,978,845
2022-07-07T00:00:00 19,668,445 681,966.7 14,211,968 31,786,189 0 66,348,569
2022-07-08T00:00:00 19,058,395 668,427.0 13,966,697 31,580,103 0 65,273,622
2022-07-09T00:00:00 19,827,540 677,465.2 14,300,922 32,287,916 0 67,093,843
2022-07-10T00:00:00 18,568,976 641,177.3 13,468,512 30,485,084 0 63,163,748
2022-07-11T00:00:00 17,681,063 614,222.3 12,942,713 29,615,778 0 60,853,776
2022-07-12T00:00:00 17,550,325 611,774.8 12,487,963 28,941,346 0 59,591,408
2022-07-13T00:00:00 17,918,817 626,714.4 12,615,071 29,286,431 0 60,447,034
2022-07-14T00:00:00 18,400,771 651,171.7 13,123,691 30,599,902 0 62,775,536
2022-07-15T00:00:00 18,243,398 647,829.0 13,444,888 32,937,709 0 65,273,824
2022-07-16T00:00:00 18,557,820 670,664.1 14,156,201 34,663,793 0 68,048,478
2022-07-17T00:00:00 18,523,988 659,963.8 13,997,952 33,856,505 0 67,038,408
2022-07-18T00:00:00 20,160,227 688,315.5 15,138,817 36,535,721 0 72,523,081
2022-07-19T00:00:00 20,922,192 750,385.3 15,808,215 38,360,177 0 75,840,969
2022-07-20T00:00:00 19,390,390 720,839.2 15,392,960 36,682,596 0 72,186,786
2022-07-21T00:00:00 21,495,915 718,839.1 15,218,790 36,908,329 0 74,341,872
2022-07-22T00:00:00 23,599,878 715,661.4 14,926,763 37,665,629 0 76,907,931
2022-07-23T00:00:00 22,811,534 727,479.5 15,129,212 37,664,469 0 76,332,695
2022-07-24T00:00:00 22,502,161 746,363.8 15,437,344 38,284,868 0 76,970,737
2022-07-25T00:00:00 20,408,396 688,271.2 14,219,936 35,628,140 0 70,944,743
2022-07-26T00:00:00 19,308,277 674,469.1 13,531,433 34,706,528 0 68,220,707
2022-07-27T00:00:00 20,857,124 748,014.4 15,195,497 38,442,238 0 75,242,874
2022-07-28T00:00:00 21,510,630 762,689.1 16,277,246 40,730,342 0 79,280,908
2022-07-29T00:00:00 21,625,865 745,266.6 17,259,796 43,154,854 0 82,785,781
2022-07-30T00:00:00 20,960,442 749,457.5 17,099,196 42,550,800 0 81,359,895
2022-07-31T00:00:00 21,186,304 794,884.7 17,998,663 45,298,046 0 85,277,898
2022-08-01T00:00:00 22,814,169 738,825.8 16,980,782 42,715,172 0 83,248,949
2022-08-02T00:00:00 20,909,352 728,714.0 16,567,033 41,792,290 0 79,997,389
2022-08-03T00:00:00 20,460,499 773,912.9 17,222,967 41,956,485 0 80,413,863
2022-08-04T00:00:00 23,510,513 743,998.2 16,624,930 42,465,311 0 83,344,752
2022-08-05T00:00:00 25,055,183 834,811.8 18,024,583 46,154,776 0 90,069,354
2022-08-06T00:00:00 27,456,827 873,856.5 17,867,054 45,277,709 0 91,475,446
2022-08-07T00:00:00 27,852,180 887,309.2 18,029,858 45,965,679 0 92,735,025
2022-08-08T00:00:00 27,579,970 967,728.9 19,250,929 49,305,821 0 97,104,448
2022-08-09T00:00:00 26,125,959 928,169.1 19,049,626 47,622,957 0 93,726,711
2022-08-10T00:00:00 27,395,172 1,044,399.6 20,269,032 51,368,487 0 100,077,092
2022-08-11T00:00:00 26,749,152 1,055,262.3 19,668,040 49,809,935 0 97,282,390
2022-08-12T00:00:00 27,600,538 1,137,154.0 20,146,997 51,330,435 0 100,215,124
2022-08-13T00:00:00 27,168,372 1,155,446.2 20,064,399 50,562,113 0 98,950,330
2022-08-14T00:00:00 24,909,652 1,114,271.4 19,945,269 50,293,229 0 96,262,421
aUSD Collateral on Karura
timestamp KAR KSM LKSM taiKSM Total
2022-05-25T00:00:00 3,787,410 707,576.8 10,186,541 0 14,681,528
2022-05-26T00:00:00 3,383,908 611,560.1 9,119,254 0 13,114,722
2022-05-27T00:00:00 3,225,655 583,984.0 8,760,679 0 12,570,318
2022-05-28T00:00:00 3,262,406 613,963.3 8,926,427 0 12,802,796
2022-05-29T00:00:00 3,346,541 648,542.9 9,446,701 0 13,441,785
2022-05-30T00:00:00 3,719,269 710,679.2 10,304,222 0 14,734,171
2022-05-31T00:00:00 3,873,783 891,172.5 10,489,781 0 15,254,737
2022-06-01T00:00:00 3,583,173 815,394.0 10,198,724 0 14,597,291
2022-06-02T00:00:00 3,622,707 817,801.5 10,248,057 0 14,688,565
2022-06-03T00:00:00 3,436,717 689,476.1 9,601,842 0 13,728,036
2022-06-04T00:00:00 3,435,842 695,789.9 9,680,038 0 13,811,670
2022-06-05T00:00:00 3,442,034 689,547.2 9,730,872 0 13,862,453
2022-06-06T00:00:00 3,476,339 727,034.2 10,024,188 0 14,227,562
2022-06-07T00:00:00 3,351,426 689,939.1 9,964,603 0 14,005,969
2022-06-08T00:00:00 3,286,016 683,342.4 9,936,292 0 13,905,651
2022-06-09T00:00:00 3,406,740 693,785.0 9,975,574 0 14,076,099
2022-06-10T00:00:00 3,193,153 607,535.8 8,831,751 0 12,632,440
2022-06-11T00:00:00 3,060,626 621,186.1 8,634,557 0 12,316,369
2022-06-12T00:00:00 2,993,526 597,004.8 7,777,334 0 11,367,864
2022-06-13T00:00:00 2,742,727 566,751.6 6,393,530 0 9,703,009
2022-06-14T00:00:00 3,019,306 610,982.6 7,106,681 0 10,736,969
2022-06-15T00:00:00 3,212,076 766,449.7 8,030,829 0 12,009,355
2022-06-16T00:00:00 2,937,299 667,271.2 6,565,903 0 10,170,473
2022-06-17T00:00:00 2,968,244 676,115.0 6,593,298 0 10,237,658
2022-06-18T00:00:00 2,957,206 620,473.8 6,564,549 0 10,142,229
2022-06-19T00:00:00 3,180,944 655,292.7 6,822,374 0 10,658,611
2022-06-20T00:00:00 3,231,552 710,358.1 7,120,949 0 11,062,858
2022-06-21T00:00:00 3,228,147 782,258.0 7,260,273 0 11,270,679
2022-06-22T00:00:00 3,183,708 733,275.3 7,080,100 0 10,997,083
2022-06-23T00:00:00 3,110,691 736,316.0 7,346,634 0 11,193,642
2022-06-24T00:00:00 3,223,059 783,479.5 7,834,265 0 11,840,803
2022-06-25T00:00:00 3,148,857 781,086.2 7,759,202 0 11,689,145
2022-06-26T00:00:00 3,626,444 808,222.5 6,845,820 0 11,280,487
2022-06-27T00:00:00 3,605,661 719,956.2 6,853,096 0 11,178,714
2022-06-28T00:00:00 3,698,800 687,686.5 6,397,519 0 10,784,005
2022-06-29T00:00:00 3,801,304 666,744.5 6,365,443 0 10,833,491
2022-06-30T00:00:00 3,882,835 592,852.0 6,008,241 0 10,483,928
2022-07-01T00:00:00 4,059,260 631,663.7 6,287,806 0 10,978,730
2022-07-02T00:00:00 4,562,861 645,961.3 6,414,225 0 11,623,048
2022-07-03T00:00:00 4,420,403 652,922.7 6,465,534 0 11,538,859
2022-07-04T00:00:00 4,721,230 672,290.2 6,824,433 0 12,217,953
2022-07-05T00:00:00 4,655,158 672,548.9 6,723,331 0 12,051,037
2022-07-06T00:00:00 4,619,995 671,571.3 6,878,963 0 12,170,529
2022-07-07T00:00:00 4,580,904 690,141.2 7,170,385 0 12,441,430
2022-07-08T00:00:00 4,560,569 693,704.3 7,281,724 0 12,535,997
2022-07-09T00:00:00 4,464,750 705,729.7 7,458,236 0 12,628,716
2022-07-10T00:00:00 4,306,606 665,716.3 7,028,016 0 12,000,338
2022-07-11T00:00:00 4,034,222 646,559.5 7,453,838 0 12,134,619
2022-07-12T00:00:00 4,067,395 631,382.7 7,621,307 0 12,320,085
2022-07-13T00:00:00 4,208,592 639,982.3 7,700,630 0 12,549,204
2022-07-14T00:00:00 4,405,164 644,179.9 8,175,598 0 13,224,942
2022-07-15T00:00:00 4,486,857 724,338.8 8,849,188 0 14,060,384
2022-07-16T00:00:00 4,490,034 745,789.3 9,125,257 0 14,361,080
2022-07-17T00:00:00 4,349,620 724,598.2 8,883,550 0 13,957,768
2022-07-18T00:00:00 4,592,360 832,010.1 9,806,741 0 15,231,111
2022-07-19T00:00:00 4,598,209 849,097.7 10,004,309 0 15,451,616
2022-07-20T00:00:00 4,595,138 782,512.2 9,281,540 0 14,659,191
2022-07-21T00:00:00 4,542,545 790,507.9 9,540,538 0 14,873,591
2022-07-22T00:00:00 4,746,705 827,019.4 10,391,415 0 15,965,139
2022-07-23T00:00:00 4,418,674 782,442.1 10,464,238 0 15,665,354
2022-07-24T00:00:00 4,311,737 763,899.2 10,198,301 0 15,273,937
2022-07-25T00:00:00 4,116,124 696,010.3 9,355,526 0 14,167,661
2022-07-26T00:00:00 3,903,343 596,148.0 9,004,347 0 13,503,837
2022-07-27T00:00:00 4,130,619 672,628.1 9,507,165 0 14,310,412
2022-07-28T00:00:00 4,368,254 745,235.1 10,256,810 0 15,370,299
2022-07-29T00:00:00 4,117,630 718,219.2 10,134,842 0 14,970,691
2022-07-30T00:00:00 4,108,322 722,222.5 10,222,468 0 15,053,012
2022-07-31T00:00:00 4,229,755 737,823.4 10,408,295 0 15,375,873
2022-08-01T00:00:00 4,106,275 713,357.3 10,257,515 0 15,077,147
2022-08-02T00:00:00 4,099,243 687,398.9 9,976,401 0 14,763,044
2022-08-03T00:00:00 4,173,187 704,185.5 10,179,102 0 15,056,475
2022-08-04T00:00:00 4,033,082 665,252.8 9,844,259 0 14,542,594
2022-08-05T00:00:00 4,167,533 681,475.4 10,209,931 0 15,058,939
2022-08-06T00:00:00 4,641,483 734,373.8 10,949,857 0 16,325,714
2022-08-07T00:00:00 4,550,684 759,059.4 10,668,546 0 15,978,289
2022-08-08T00:00:00 4,569,666 727,252.6 11,959,969 0 17,256,887
2022-08-09T00:00:00 4,221,155 652,504.1 11,202,429 0 16,076,088
2022-08-10T00:00:00 4,462,958 691,281.7 11,592,015 0 16,746,255
2022-08-11T00:00:00 4,189,391 653,637.0 11,260,066 0 16,103,094
2022-08-12T00:00:00 4,158,005 651,302.4 11,257,498 0 16,066,806
2022-08-13T00:00:00 4,194,475 658,894.8 11,355,257 0 16,208,627
2022-08-14T00:00:00 3,782,947 638,729.4 10,855,147 0 15,276,823
2022-08-15T00:00:00 3,789,446 634,209.0 10,749,360 0 15,173,016
2022-08-16T00:00:00 3,508,774 609,514.7 10,425,502 0 14,543,791
2022-08-17T00:00:00 3,436,024 595,130.0 9,771,686 0 13,802,840
2022-08-18T00:00:00 3,367,908 605,500.7 9,460,063 0 13,433,472
2022-08-19T00:00:00 3,120,498 517,378.3 8,522,586 0 12,160,462
2022-08-20T00:00:00 3,080,131 514,118.3 8,472,071 0 12,066,321
2022-08-21T00:00:00 3,364,522 538,329.1 8,891,196 0 12,794,048
2022-08-22T00:00:00 3,491,303 510,825.0 7,985,493 0 11,987,621
aUSD Collateral in Aggregate
timestamp ACA DOT KAR KSM LCDOT LDOT LKSM Total
2022-05-25T00:00:00 33,726,475 879,184.8 3,787,410 707,576.8 19,267,881 36,049,747 10,186,541 104,604,816
2022-05-26T00:00:00 30,879,726 773,513.2 3,383,908 611,560.1 17,514,683 34,094,350 9,119,254 96,376,994
2022-05-27T00:00:00 29,399,218 758,920.9 3,225,655 583,984.0 17,289,830 34,175,171 8,760,679 94,193,458
2022-05-28T00:00:00 30,383,749 792,747.5 3,262,406 613,963.3 18,195,952 36,180,796 8,926,427 98,356,041
2022-05-29T00:00:00 31,538,173 831,780.5 3,346,541 648,542.9 19,039,993 37,364,204 9,446,701 102,215,935
2022-05-30T00:00:00 37,110,651 877,557.0 3,719,269 710,679.2 20,219,540 39,561,582 10,304,222 112,503,502
2022-05-31T00:00:00 35,937,942 835,802.9 3,873,783 891,172.5 20,012,386 40,073,959 10,489,781 112,114,827
2022-06-01T00:00:00 32,494,525 813,376.8 3,583,173 815,394.0 17,971,424 36,495,390 10,198,724 102,372,007
2022-06-02T00:00:00 34,622,926 958,341.1 3,622,707 817,801.5 18,980,145 38,373,731 10,248,057 107,623,709
2022-06-03T00:00:00 31,155,569 828,464.6 3,436,717 689,476.1 17,933,123 36,340,325 9,601,842 99,985,518
2022-06-04T00:00:00 32,049,466 834,350.1 3,435,842 695,789.9 18,027,942 36,871,081 9,680,038 101,594,509
2022-06-05T00:00:00 31,557,720 835,901.0 3,442,034 689,547.2 18,079,058 37,085,359 9,730,872 101,420,491
2022-06-06T00:00:00 32,149,212 858,791.5 3,476,339 727,034.2 18,148,319 37,656,963 10,024,188 103,040,847
2022-06-07T00:00:00 31,450,008 917,979.3 3,351,426 689,939.1 17,940,867 36,946,590 9,964,603 101,261,412
2022-06-08T00:00:00 30,275,763 915,780.5 3,286,016 683,342.4 17,413,019 36,642,380 9,936,292 99,152,594
2022-06-09T00:00:00 30,309,521 922,628.8 3,406,740 693,785.0 17,700,179 37,755,726 9,975,574 100,764,155
2022-06-10T00:00:00 28,214,617 875,142.9 3,193,153 607,535.8 16,656,549 35,508,739 8,831,751 93,887,488
2022-06-11T00:00:00 26,233,595 805,465.4 3,060,626 621,186.1 15,491,476 33,084,923 8,634,557 87,931,828
2022-06-12T00:00:00 22,991,572 755,318.7 2,993,526 597,004.8 14,364,876 30,900,261 7,777,334 80,379,892
2022-06-13T00:00:00 22,496,740 603,357.8 2,742,727 566,751.6 12,804,107 28,265,405 6,393,530 73,872,618
2022-06-14T00:00:00 23,222,224 632,095.6 3,019,306 610,982.6 13,644,103 30,129,663 7,106,681 78,365,054
2022-06-15T00:00:00 24,635,191 795,036.9 3,212,076 766,449.7 15,350,110 34,491,243 8,030,829 87,280,935
2022-06-16T00:00:00 21,455,791 698,138.4 2,937,299 667,271.2 13,074,550 28,884,839 6,565,903 74,283,791
2022-06-17T00:00:00 21,588,106 708,291.1 2,968,244 676,115.0 13,556,319 30,107,827 6,593,298 76,198,201
2022-06-18T00:00:00 20,495,011 698,151.5 2,957,206 620,473.8 12,940,192 29,219,980 6,564,549 73,495,562
2022-06-19T00:00:00 21,666,317 736,484.7 3,180,944 655,292.7 13,704,383 30,874,634 6,822,374 77,640,430
2022-06-20T00:00:00 21,933,866 757,604.7 3,231,552 710,358.1 15,344,393 32,331,287 7,120,949 81,430,009
2022-06-21T00:00:00 22,391,510 783,003.7 3,228,147 782,258.0 15,454,004 32,076,181 7,260,273 81,975,377
2022-06-22T00:00:00 21,110,303 751,727.2 3,183,708 733,275.3 14,816,964 30,849,626 7,080,100 78,525,704
2022-06-23T00:00:00 22,411,324 781,462.3 3,110,691 736,316.0 15,312,177 32,069,474 7,346,634 81,768,078
2022-06-24T00:00:00 23,120,727 811,492.4 3,223,059 783,479.5 16,312,613 34,050,408 7,834,265 86,136,044
2022-06-25T00:00:00 22,328,789 780,487.2 3,148,857 781,086.2 15,826,700 33,575,946 7,759,202 84,201,067
2022-06-26T00:00:00 21,583,988 798,118.8 3,626,444 808,222.5 15,836,322 32,745,570 6,845,820 82,244,487
2022-06-27T00:00:00 21,879,730 795,040.0 3,605,661 719,956.2 15,324,248 32,619,704 6,853,096 81,797,436
2022-06-28T00:00:00 19,847,103 737,016.7 3,698,800 687,686.5 14,300,964 30,529,655 6,397,519 76,198,745
2022-06-29T00:00:00 19,494,983 703,022.7 3,801,304 666,744.5 13,757,575 29,397,328 6,365,443 74,186,400
2022-06-30T00:00:00 19,174,576 680,719.4 3,882,835 592,852.0 13,339,374 28,703,383 6,008,241 72,381,980
2022-07-01T00:00:00 18,991,081 667,664.3 4,059,260 631,663.7 13,317,313 29,121,571 6,287,806 73,076,359
2022-07-02T00:00:00 18,563,027 671,815.6 4,562,861 645,961.3 13,376,045 29,315,228 6,414,225 73,549,163
2022-07-03T00:00:00 18,406,482 706,142.6 4,420,403 652,922.7 13,374,999 29,354,634 6,465,534 73,381,117
2022-07-04T00:00:00 20,295,676 728,463.1 4,721,230 672,290.2 13,951,594 30,848,872 6,824,433 78,042,557
2022-07-05T00:00:00 18,995,785 707,868.0 4,655,158 672,548.9 13,447,543 29,737,130 6,723,331 74,939,363
2022-07-06T00:00:00 19,445,111 710,456.6 4,619,995 671,571.3 13,631,510 30,191,768 6,878,963 76,149,375
2022-07-07T00:00:00 19,668,445 681,966.7 4,580,904 690,141.2 14,211,968 31,786,189 7,170,385 78,789,999
2022-07-08T00:00:00 19,058,395 668,427.0 4,560,569 693,704.3 13,966,697 31,580,103 7,281,724 77,809,619
2022-07-09T00:00:00 19,827,540 677,465.2 4,464,750 705,729.7 14,300,922 32,287,916 7,458,236 79,722,559
2022-07-10T00:00:00 18,568,976 641,177.3 4,306,606 665,716.3 13,468,512 30,485,084 7,028,016 75,164,087
2022-07-11T00:00:00 17,681,063 614,222.3 4,034,222 646,559.5 12,942,713 29,615,778 7,453,838 72,988,395
2022-07-12T00:00:00 17,550,325 611,774.8 4,067,395 631,382.7 12,487,963 28,941,346 7,621,307 71,911,493
2022-07-13T00:00:00 17,918,817 626,714.4 4,208,592 639,982.3 12,615,071 29,286,431 7,700,630 72,996,238
2022-07-14T00:00:00 18,400,771 651,171.7 4,405,164 644,179.9 13,123,691 30,599,902 8,175,598 76,000,478
2022-07-15T00:00:00 18,243,398 647,829.0 4,486,857 724,338.8 13,444,888 32,937,709 8,849,188 79,334,207
2022-07-16T00:00:00 18,557,820 670,664.1 4,490,034 745,789.3 14,156,201 34,663,793 9,125,257 82,409,559
2022-07-17T00:00:00 18,523,988 659,963.8 4,349,620 724,598.2 13,997,952 33,856,505 8,883,550 80,996,177
2022-07-18T00:00:00 20,160,227 688,315.5 4,592,360 832,010.1 15,138,817 36,535,721 9,806,741 87,754,192
2022-07-19T00:00:00 20,922,192 750,385.3 4,598,209 849,097.7 15,808,215 38,360,177 10,004,309 91,292,585
2022-07-20T00:00:00 19,390,390 720,839.2 4,595,138 782,512.2 15,392,960 36,682,596 9,281,540 86,845,976
2022-07-21T00:00:00 21,495,915 718,839.1 4,542,545 790,507.9 15,218,790 36,908,329 9,540,538 89,215,464
2022-07-22T00:00:00 23,599,878 715,661.4 4,746,705 827,019.4 14,926,763 37,665,629 10,391,415 92,873,070
2022-07-23T00:00:00 22,811,534 727,479.5 4,418,674 782,442.1 15,129,212 37,664,469 10,464,238 91,998,049
2022-07-24T00:00:00 22,502,161 746,363.8 4,311,737 763,899.2 15,437,344 38,284,868 10,198,301 92,244,673
2022-07-25T00:00:00 20,408,396 688,271.2 4,116,124 696,010.3 14,219,936 35,628,140 9,355,526 85,112,404
2022-07-26T00:00:00 19,308,277 674,469.1 3,903,343 596,148.0 13,531,433 34,706,528 9,004,347 81,724,544
2022-07-27T00:00:00 20,857,124 748,014.4 4,130,619 672,628.1 15,195,497 38,442,238 9,507,165 89,553,286
2022-07-28T00:00:00 21,510,630 762,689.1 4,368,254 745,235.1 16,277,246 40,730,342 10,256,810 94,651,207
2022-07-29T00:00:00 21,625,865 745,266.6 4,117,630 718,219.2 17,259,796 43,154,854 10,134,842 97,756,472
2022-07-30T00:00:00 20,960,442 749,457.5 4,108,322 722,222.5 17,099,196 42,550,800 10,222,468 96,412,906
2022-07-31T00:00:00 21,186,304 794,884.7 4,229,755 737,823.4 17,998,663 45,298,046 10,408,295 100,653,772
2022-08-01T00:00:00 22,814,169 738,825.8 4,106,275 713,357.3 16,980,782 42,715,172 10,257,515 98,326,096
2022-08-02T00:00:00 20,909,352 728,714.0 4,099,243 687,398.9 16,567,033 41,792,290 9,976,401 94,760,433
2022-08-03T00:00:00 20,460,499 773,912.9 4,173,187 704,185.5 17,222,967 41,956,485 10,179,102 95,470,339
2022-08-04T00:00:00 23,510,513 743,998.2 4,033,082 665,252.8 16,624,930 42,465,311 9,844,259 97,887,346
2022-08-05T00:00:00 25,055,183 834,811.8 4,167,533 681,475.4 18,024,583 46,154,776 10,209,931 105,128,294
2022-08-06T00:00:00 27,456,827 873,856.5 4,641,483 734,373.8 17,867,054 45,277,709 10,949,857 107,801,160
2022-08-07T00:00:00 27,852,180 887,309.2 4,550,684 759,059.4 18,029,858 45,965,679 10,668,546 108,713,315
2022-08-08T00:00:00 27,579,970 967,728.9 4,569,666 727,252.6 19,250,929 49,305,821 11,959,969 114,361,335
2022-08-09T00:00:00 26,125,959 928,169.1 4,221,155 652,504.1 19,049,626 47,622,957 11,202,429 109,802,800
2022-08-10T00:00:00 27,395,172 1,044,399.6 4,462,958 691,281.7 20,269,032 51,368,487 11,592,015 116,823,346
2022-08-11T00:00:00 26,749,152 1,055,262.3 4,189,391 653,637.0 19,668,040 49,809,935 11,260,066 113,385,484
2022-08-12T00:00:00 27,600,538 1,137,154.0 4,158,005 651,302.4 20,146,997 51,330,435 11,257,498 116,281,930
2022-08-13T00:00:00 27,168,372 1,155,446.2 4,194,475 658,894.8 20,064,399 50,562,113 11,355,257 115,158,957
2022-08-14T00:00:00 24,909,652 1,114,271.4 3,782,947 638,729.4 19,945,269 50,293,229 10,855,147 111,539,244
2022-08-15T00:00:00 0 0.0 3,789,446 634,209.0 0 0 10,749,360 15,173,016
2022-08-16T00:00:00 0 0.0 3,508,774 609,514.7 0 0 10,425,502 14,543,791
2022-08-17T00:00:00 0 0.0 3,436,024 595,130.0 0 0 9,771,686 13,802,840
2022-08-18T00:00:00 0 0.0 3,367,908 605,500.7 0 0 9,460,063 13,433,472
2022-08-19T00:00:00 0 0.0 3,120,498 517,378.3 0 0 8,522,586 12,160,462
2022-08-20T00:00:00 0 0.0 3,080,131 514,118.3 0 0 8,472,071 12,066,321
2022-08-21T00:00:00 0 0.0 3,364,522 538,329.1 0 0 8,891,196 12,794,048
2022-08-22T00:00:00 0 0.0 3,491,303 510,825.0 0 0 7,985,493 11,987,621
---
title: "Acala / Karura aUSD Dashboard"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    social: menu
    source_code: embed
flexdashboard::valueBox(): 
orientation: rows 
source_code: embed 
vertical_layout: fill
---

```{css custom1, echo=FALSE}
.dataTables_scrollBody {
    max-height: 100% !important;
}
```

```{r global, include=FALSE}
library(knitr)
knitr::opts_chunk$set(
  message = FALSE,
  warning = FALSE,
  comment = "#>"
)

library(ggplot2)
library(ggpubr)
# library(dygraphs)
library(kableExtra)
library(formattable)
library(lubridate)
library(flexdashboard)
library(DT)
library(subscanr)
library(formattable)
library(ghql)
x <- GraphqlClient$new()

# Helper function to concat
`%+%` <- function(a, b) paste0(a, b)

window <- 90

k_collateral <- getLoansDailyCollateral_acala_loan("Karura", window)
k_current_collateral <- k_collateral[Date == max(Date), .(collateral.id, depositVolumeUSD)]
k_current_collateral <- k_current_collateral[depositVolumeUSD > 0]
k_collateral[, pct := round(depositVolumeUSD / sum(depositVolumeUSD), 3) * 100, by = "Date"]
k_collateral[, labs := pct %+% "%", by = "Date"]

setorder(k_collateral, pct)
k_current_collateral <- k_collateral[Date == max(Date), .(collateral.id, depositVolumeUSD)]
k_current_collateral <- k_collateral[depositVolumeUSD > 0 & Date == max(Date), .(collateral.id, depositVolumeUSD, pct, labs)]
max(k_collateral$Date)

a_collateral <- getLoansDailyCollateral_acala_loan("acala", window)
a_collateral[, pct := round(depositVolumeUSD / sum(depositVolumeUSD), 3) * 100, by = "Date"]
a_collateral[, labs := pct %+% "%", by = "Date"]
setorder(a_collateral, pct)
a_current_collateral <- a_collateral[depositVolumeUSD > 0 & Date == max(Date), .(collateral.id, depositVolumeUSD, pct, labs)]
max(a_collateral$Date)

# both_collateral <- rbind(k_collateral, a_collateral, fill = TRUE)
# both_current_collateral <- both_collateral[Date == max(Date), .(collateral.id, depositVolumeUSD)]
both_collateral <- rbind(k_collateral, a_collateral)
both_collateral[, pct := NULL]
both_collateral[, labs := NULL]
both_collateral[, pct := round(depositVolumeUSD / sum(depositVolumeUSD), 3) * 100, by = "timestamp"]
both_collateral[, labs := pct %+% "%"]
setorder(both_collateral, pct)
both_collateral <- both_collateral[depositVolumeUSD > 0]
both_current_collateral <- both_collateral[depositVolumeUSD > 0 & Date == max(Date), .(collateral.id, depositVolumeUSD, pct, labs)]

# Collateralization Ratio
k_cratio <- k_collateral[, sum(depositVolumeUSD) / sum(debitVolumeUSD), by = Date] %>%
  setnames("V1", "Karura Collateralization Ratio")
  
a_cratio <- a_collateral[, sum(depositVolumeUSD) / sum(debitVolumeUSD), by = Date] %>%
  setnames("V1", "Acala Collateralization Ratio")
  
both_cratio <- both_collateral[, sum(depositVolumeUSD) / sum(debitVolumeUSD), by = Date] %>%
  setnames("V1", "Combined Collateralization Ratio")

# Stablecoin percentage of collateral
k_pct_stablecoin <- k_collateral[, (sum(debitVolumeUSD) / sum(depositVolumeUSD))*100, by = Date] %>%
  setnames("V1", "Karura Stablecoin Percentage of Collateral")

a_pct_stablecoin <- a_collateral[, (sum(debitVolumeUSD) / sum(depositVolumeUSD))*100, by = Date] %>%
  setnames("V1", "Acala Stablecoin Percentage of Collateral")

both_pct_stablecoin <- both_collateral[, (sum(debitVolumeUSD) / sum(depositVolumeUSD))*100, by = Date] %>%
  setnames("V1", "Combined Stablecoin Percentage of Collateral")

a_params_current <- getLoansCollateralParams_acala_loan("Acala")
k_params_current <- getLoansCollateralParams_acala_loan("Karura")

cols <- c("collateral.id","maximumTotalDebitValue","liquidationRatio","requiredCollateralRatio")
a_params_current[, ..cols]
k_params_current[, ..cols]


a_params <- getLoansCollateralParamsHistory_acala_loan("Acala")
# a_params

k_params <- getLoansCollateralParamsHistory_acala_loan("Karura")

params <- rbind(a_params, k_params)
params[, Date := as.Date(startAt)]
params[, Block := as.numeric(startAtBlockId)]
params[, maximumTotalDebitValue := as.numeric(maximumTotalDebitValue)]
params[, interestRatePerSec := as.numeric(interestRatePerSec)]
params[, interestRateAnnualized := ((interestRatePerSec / 1e18 + 1) ** (365 * 86400) - 1)]
# summary(params$interestRateAnnualized)

# names(params)
# str(params)

params_long <- melt(params, id.vars=c("collateral.id", "Block"), measure.vars=c("maximumTotalDebitValue","interestRateAnnualized","liquidationRatio","liquidationPenalty","requiredCollateralRatio"))
params_long <- unique(params_long)
setorder(params_long, collateral.id, variable, Block)

params_long[, .N, by = collateral.id]


tag <- "KAR"
params_long[collateral.id == tag & Block > 376050]

kar_params <- ggplot(params_long[collateral.id == tag & Block > 376050], aes(Block, value)) +
  geom_line() +
  facet_wrap(vars(variable), scales = "free_y", nrow = 2, strip.position = "top") +
  theme(strip.background = element_blank(), strip.placement = "outside") +
  theme(axis.text.x=element_text(angle = -90, hjust = 0))

#   theme_void() # remove background, grid, numeric labels

# Liquidity Pool TVL ($3.72M) = totalDefiTvl = totalDexTvl + totalDexLockedTvl + homaLocked + stableCoinTvl
kdex <- getDailyPools_acala_dex("karura", window) %>%
  setorder(Date, pair)
adex <- getDailyPools_acala_dex("acala", window) %>%
  setorder(Date, pair)
adaily <- adex[, max(updateAtBlock.id), by = Date] %>%
  setnames("V1", "blockAcala")
kdaily <- kdex[, max(updateAtBlock.id), by = Date] %>%
  setnames("V1", "blockKarura")
dailyTVL <- merge(adaily, kdaily, by = 'Date')

library(reticulate)
# use_python("/opt/homebrew/bin/python3.9")

```

```{python, include=FALSE}
from substrateinterface import SubstrateInterface

import pandas as pd

def getFeePayment(network):
    if network=="Karura":
        url = 'wss://karura.polkawallet.io'
        token = 'KUSD'
    else:
        url = 'wss://acala-rpc-0.aca-api.network'
        token = 'AUSD'
    substrate = SubstrateInterface(url)
    data = []
    for block_id in r.blocks:
        hash = substrate.get_block_hash(0)
        fee = substrate.query(module='TransactionPayment',storage_function='TransactionFeePaid', block_hash = hash)
        outi = {"Block": block_id, 'aUSD': ausd.value / 10**12}
        data.append(outi)
    out = pd.DataFrame(data)
    return out


def getTotalIssuance(network):
    if network=="Karura":
        url = 'wss://karura.polkawallet.io'
        token = 'KUSD'
    else:
        url = 'wss://acala-rpc-0.aca-api.network'
        token = 'AUSD'
    substrate = SubstrateInterface(url)
    data = []
    for block_id in r.blocks:
        hash = substrate.get_block_hash(int(block_id))
        ausd = substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': token}], block_hash = hash)
        outi = {"Block": block_id, 'aUSD': ausd.value / 10**12}
        data.append(outi)
    out = pd.DataFrame(data)
    return out

```



```{r tvl, cache = TRUE, include=FALSE}

  blocks = as.character(dailyTVL$blockKarura)
  kusd = py$getTotalIssuance("Karura")
  
  blocks = as.character(dailyTVL$blockAcala)
  ausd = py$getTotalIssuance("Acala")

  dailyTVL[, blockAcala  := as.numeric(blockAcala)]  
  dailyTVL[, blockKarura := as.numeric(blockKarura)]  
  kusd$Block <- as.numeric(kusd$Block)
  ausd$Block <- as.numeric(ausd$Block)
  
  dailyTVL <- merge(dailyTVL, kusd, by.x = "blockKarura", by.y = "Block") %>%
    setnames("aUSD", "aUSD_Karura")
  dailyTVL <- merge(dailyTVL, ausd, by.x = "blockAcala", by.y = "Block") %>%
    setnames("aUSD", "aUSD_Acala")
  dailyTVL[, aUSD_Total := aUSD_Karura + aUSD_Acala]
  
```

# Overview {.tabset}

Row
----

```{r}
myFormat <- function(x, prefix = "", suffix = "") prefix %+% (x %>% tail(1) %>% as.numeric %>% round(2) %>% format(nsmall=1, big.mark=",")) %+% suffix

ausd_total <- myFormat(dailyTVL[, aUSD_Total], "$", " USD")
ausd_karura <- myFormat(dailyTVL[, aUSD_Karura], "$", " USD")
ausd_acala <- myFormat(dailyTVL[, aUSD_Acala], "$", " USD")

cratio_combined <- myFormat(both_cratio$`Combined Collateralization Ratio`, suffix = "x")
cratio_karura <- myFormat(k_cratio$`Karura Collateralization Ratio`, suffix = "x")
cratio_acala <- myFormat(a_cratio$`Acala Collateralization Ratio`, suffix = "x")

pct_combined <- myFormat(both_pct_stablecoin$`Combined Stablecoin Percentage of Collateral`, suffix="%")
pct_karura <- myFormat(k_pct_stablecoin$`Karura Stablecoin Percentage of Collateral`, suffix="%")
pct_acala <- myFormat(a_pct_stablecoin$`Acala Stablecoin Percentage of Collateral`, suffix="%")

```

### aUSD Outstanding

`r valueBox(value = ausd_total)`

### aUSD Collateral Ratio

`r valueBox(value = cratio_combined)`

### Percentage of Collateral

`r valueBox(value = pct_combined)`


Row
----

* As of *`r tail(dailyTVL$Date, 1)`*, the combined aUSD value minted is *`r ausd_total`*.  

* *`r ausd_acala`* on Acala (as of block number *`r tail(dailyTVL$blockAcala, 1)`*) and *`r ausd_karura`* on Karura (as of block number *`r tail(dailyTVL$blockKarura, 1)`*). 

* The collateralizaion ratio is the value of the collateteral deposited divided by the amount of aUSD minted.  

* The combined collateralization ratio is *`r cratio_combined`*.  

* The ratio for the individual parachains are as follows: *`r cratio_acala`* for Acala and *`r cratio_karura`* for Karura.

* The reciprocal of the collareralization ratio shows the stablecoin issuance as a percentage of collateral, which is *`r pct_combined`* in aggregate.  

* Specifically, *`r pct_acala`* for Acala and *`r pct_karura`* for Karura.

# Charts {.tabset}

Row
----

### Components of Total Value Locked

```{r k_plot1}

dat <- melt(data = dailyTVL[, .(Date, aUSD_Karura, aUSD_Acala)], 
      id.vars = "Date",
      value.name = "aUSD")
dat[, aUSD := aUSD / 1e6]
 
# Stacked
ggplot(dat, aes(fill=variable, y=aUSD, x=Date)) + 
    geom_bar(position="stack", stat="identity") +
    ggtitle(label="Issuance of aUSD") + 
    ylab("aUSD (in millions USD)")

```


Row
----

```{r pie, out.width = '33%'}
# ggpie chart
a_df <- as.data.frame(a_current_collateral)
k_df <- as.data.frame(k_current_collateral)
both_df <- as.data.frame(both_current_collateral)

ggpie(a_df, "pct", label = "labs", fill = "collateral.id", color = "white", lab.font = c(2, "bold", "red"), main = "aUSD collateral on Acala")

ggpie(k_df, "pct", label = "labs", fill = "collateral.id", color = "white", lab.font = c(2, "bold", "red"), main = "aUSD collateral on Karura")

ggpie(both_df, "pct", label = "labs", fill = "collateral.id", color = "white", lab.font = c(2, "bold", "red"), main = "aUSD collateral in Aggregate")

```

Row
----

```{r donut, out.width = '33%'}

# df <- data.frame(group = c("A", "B", "C","D"), value = c(1, 21, 26, 52))
# df$labs <- paste0(df$group, " (", df$value, "%)")
# ggdonutchart(df, "value", label = "labs", fill = "group", color = "white")

ggdonutchart(a_df, "pct", label = "labs", fill = "collateral.id", color = "white", lab.font = c(2, "bold", "red"), main = "aUSD collateral on Acala")

ggdonutchart(k_df, "pct", label = "labs", fill = "collateral.id", color = "white", lab.font = c(2, "bold", "red"), main = "aUSD collateral on Karura")

ggdonutchart(both_df, "pct", label = "labs", fill = "collateral.id", color = "white", lab.font = c(2, "bold", "red"), main = "aUSD collateral in Aggregate")

```

Row
----

```{r lollipop, out.width = '33%'}

# lollipop
ggplot(a_current_collateral, aes(x=collateral.id, y=depositVolumeUSD)) +
  geom_segment( aes(x=collateral.id, xend=collateral.id, y=0, yend=depositVolumeUSD)) +
  geom_point( size=5, color="red", fill=alpha("orange", 0.3), alpha=0.7, shape=21, stroke=2) +
  ggtitle("aUSD collateral on Acala", ) +
theme(plot.title = element_text(color="red", size=14, face="plain"),
axis.title.x = element_blank(),
axis.title.y = element_text(color="#993333", size=14, face="plain")
)  

ggplot(k_current_collateral, aes(x=collateral.id, y=depositVolumeUSD)) +
  geom_segment( aes(x=collateral.id, xend=collateral.id, y=0, yend=depositVolumeUSD)) +
  geom_point( size=5, color="red", fill=alpha("orange", 0.3), alpha=0.7, shape=21, stroke=2) +
  ggtitle("aUSD collateral on Karura", ) +
theme(plot.title = element_text(color="red", size=14, face="plain"),
axis.title.x = element_blank(),
axis.title.y = element_text(color="#993333", size=14, face="plain")
)  

ggplot(both_current_collateral, aes(x=collateral.id, y=depositVolumeUSD)) +
  geom_segment( aes(x=collateral.id, xend=collateral.id, y=0, yend=depositVolumeUSD)) +
  geom_point( size=5, color="red", fill=alpha("orange", 0.3), alpha=0.7, shape=21, stroke=2) +
  ggtitle("aUSD collateral in Aggregate", ) +
theme(plot.title = element_text(color="red", size=14, face="plain"),
axis.title.x = element_blank(),
axis.title.y = element_text(color="#993333", size=14, face="plain")
)  

```


Row
----

```{r collateralization_ratio, out.width = '33%'}

ggline(a_cratio, x = "Date", y = "Acala Collateralization Ratio", title = "Acala Collateralization Ratio", color = "red", ylab = "depositVolumeUSD / debitVolumeUSD", xlab = "")

ggline(k_cratio, x = "Date", y = "Karura Collateralization Ratio", title = "Karura Collateralization Ratio", color = "blue", ylab = "depositVolumeUSD / debitVolumeUSD", xlab = "")

ggline(both_cratio, x = "Date", y = "Combined Collateralization Ratio", title = "Combined Collateralization Ratio", color = "orange", ylab = "depositVolumeUSD / debitVolumeUSD", xlab = "")

```


Row
----

```{r pct_of_collatearl, out.width = '33%'}

# Stablecoin percentage of collateral

ggline(a_pct_stablecoin, x = "Date", y = "Acala Stablecoin Percentage of Collateral", title = "Acala Stablecoin percentage of collateral", color = "red", ylab = "debitVolumeUSD / depositVolumeUSD", xlab = "")

ggline(k_pct_stablecoin, x = "Date", y = "Karura Stablecoin Percentage of Collateral", title = "Karura Stablecoin percentage of collateral", color = "blue", ylab = "debitVolumeUSD / depositVolumeUSD", xlab = "")

ggline(both_pct_stablecoin, x = "Date", y = "Combined Stablecoin Percentage of Collateral", title = "Combined Stablecoin percentage of collateral", color = "orange", ylab = "debitVolumeUSD / depositVolumeUSD", xlab = "")

```


# Minting data {.tabset}

Row
----

### aUSD Issuance

```{r ausd}

knitr::kable(dailyTVL, escape = FALSE, format.args = list(big.mark = ",")) %>%
  kable_styling()

```

Row
----

### Sources and Notes

Please click on the *Source Code* link at the top of the document to see the full source code.  Here is a summary:

#### aUSD
- aUDS (or kUSD) obtained from the [py-substrate-interface](https://github.com/polkascan/py-substrate-interface) using function *substrate.query(module='Tokens',storage_function='TotalIssuance', params = [{'Token': 'AUSD'}], block_hash = hash)*


# Collateral data {.tabset}

Row
----

### aUSD Collateral

```{r collateal}

k_collateral_wide <- dcast(k_collateral, timestamp ~ collateral.id, value.var = "depositVolumeUSD", fun.aggregate = sum)
k_collateral_wide[, Total := rowSums(k_collateral_wide[, -1])]

a_collateral_wide <- dcast(a_collateral, timestamp ~ collateral.id, value.var = "depositVolumeUSD", fun.aggregate = sum)
a_collateral_wide[, Total := rowSums(a_collateral_wide[, -1])]

both_collateral_wide <- dcast(both_collateral, timestamp ~ collateral.id, value.var = "depositVolumeUSD", fun.aggregate = sum)
both_collateral_wide[, Total := rowSums(both_collateral_wide[, -1])]

knitr::kable(a_collateral_wide, escape = FALSE, format.args = list(big.mark = ","), caption = "aUSD Collateral on Acala") %>%
  kable_styling()

knitr::kable(k_collateral_wide, escape = FALSE, format.args = list(big.mark = ","), caption = "aUSD Collateral on Karura") %>%
  kable_styling()

knitr::kable(both_collateral_wide, escape = FALSE, format.args = list(big.mark = ","), caption = "aUSD Collateral in Aggregate") %>%
  kable_styling()

```